package com.geekaca.d06.homework;

import java.util.HashMap;
import java.util.Map;

public class Test2 {
    public static void main(String[] args) {
        String str = "aababcabcdabcde";
        Map<Character, Integer> mapWordsCount = new HashMap<>();
        for (int i = 0; i < str.length(); i++) {
            char currentChar = str.charAt(i);
            if (!mapWordsCount.containsKey(currentChar)) {
                mapWordsCount.put(currentChar, 1);
            } else {
                mapWordsCount.put(currentChar, mapWordsCount.get(currentChar) + 1);
            }
        }

        mapWordsCount.forEach((k, v) -> System.out.println(k + ":" + v));
    }
}
